// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

// Test the propagation of maximum and minimum size through nested grid layouts

Btn := Rectangle {
    property <string> text;

    t := Text {
        text: root.text;
        width: 100%; height: 100%;
    }

    accessible-label: text;
    accessible-role: button;
}

Cb := Rectangle {
    property <string> text;
    accessible-label: text;
    t := Text { }
    accessible-description <=> t.text;
    accessible-role: checkbox;
    accessible-checked: true;
}

TestCase := Rectangle {
    width: 300phx;
    height: 300phx;

    vl := VerticalLayout {
        b1 := Btn {
            text: "plus";
        }

        txt := Text {
            text: "automatic text value";
        }


        b2 := Btn {
            text : "minus";
        }

        cb := Cb { text: "hello"; }
    }

    for t in ["abc"] : Text { text: t; accessible-description: t;  }

    property<AccessibleRole> materialized_b1_role: b1.accessible_role;
    property<string> materialized_b2_label: b2.accessible-label;
    property<string> materialized_vl_label: vl.accessible-label;
    property<AccessibleRole> materialized_vl_role: vl.accessible-role;
    property<AccessibleRole> materialized_txt_role: txt.accessible-role;
    property<string> materialized_txt_label: txt.accessible-label;

    property <bool> test:
        materialized_b1_role == AccessibleRole.button && materialized_b2_label == "minus"
        && materialized_vl_label == "" && materialized_vl_role == AccessibleRole.none
        && materialized_txt_label == "automatic text value" && materialized_txt_role == AccessibleRole.text
        && cb.accessible-checked && !b1.accessible-checked;
}


/*

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
```


```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
```

```js
var instance = new slint.TestCase();
assert(instance.test);
```

*/
